(function($, im, doc) {
	$.plusReady(function() {
		var transDoc = document.getElementById("transfer_accounts");
		//console.log(im.roomType); 
		if(im.roomType == 2) {
			transDoc.parentNode.remove();
		} else {
			transDoc.addEventListener('tap', function() {
				//plus.webview.close('red_packet','none');
				mui.openWindow({
					url: '../../pages/coin/remove.html',
					id: 'remove',
					extras: {
						roomId: im.roomId,
						roomType: im.roomType,
						pageType: 'remove'
					},
					createNew: false
				});
			});
		}
		doc.getElementById("red_packet").addEventListener('tap', function() {
			//plus.webview.close('red_packet','none');
			mui.openWindow({
				url: '../../pages/coin/red_packet.html',
				id: 'red_packet',
				extras: {
					roomId: im.roomId,
					roomType: im.roomType,
					pageType: 'hongbao'
				},
				createNew: false
			});
		});
		window.addEventListener('PAY_HONGBAO_SUCC', function(event) {
			var hash = event.detail.hash;
			var fromtype = event.detail.fromtype;
			var remark = event.detail.remark;
			var money = event.detail.money;
			var pageType = event.detail.pageType;
			im.sendMsg({
				sender: 'self',
				type: pageType,
				content: hash,
				extras: {
					fromtype: fromtype,
					remark: remark,
					money: money

				}
			});
			im.playsendSound('hb');
			im.closeFooterBox();

		});
		window.addEventListener('GET_HONGBAO_SUCC', function(event) {
			var detail = event.detail;
			im.sendMsg({
				sender: 'self',
				type: 'recvzhuanzhang',
				content: im.user_name,
				extras: {
					money : detail.money,
					coinname : detail.coinname
				}
			});
			im.playsendSound('zz');
			//通知发包方确认红包
			var tradeId = detail.tradeId;
			var senddata = {
				tradeId : tradeId,
				type : 'hasHongbao',
				money : detail.money,
				tid : detail.tid,
				username : im.user_name,
				user_id : im.uid,
				coinname : detail.coinname
			};
			mui.fire(im.mainWin, 'hasHongbao', senddata);
			
		});

		$('#msg-list').on('tap', '.tradearea', function() {
			
			var hash = this.getAttribute('data-path');
			var url = "../../pages/coin/showtrade.html";
			mui.openWindow({
				url: url,
				id: 'showtrade',
				createNew: true,
				extras: {
					roomId: im.roomId,
					hash: hash
				}
			});
		});
	});
}(mui, im, document));